<?php
namespace App\Controller;

class ShopController extends BaseController
{
    public function getProductJson()
    {
        $product = D("Product")->getProduct(I("get."), true , true);
        $this->ajaxReturn($product);
    }

    public function getProductListJson()
    {
        $product = D("Product")->getProductList();
        $this->ajaxReturn($product);
    }

    public function getMenuJson()
    {
        $menu = D("Menu")->getMenu(array("id" => I("get.id")));
        $this->ajaxReturn($menu);
    }

    public function getMenuListJson()
    {
        $menu = D("Menu")->getMenuList();
        $this->ajaxReturn($menu);
    }

    public function getMenuTreeListJson()
    {
        $menu = D("Menu")->getMenuList();
        $menuTree = list_to_tree($menu, 'id', 'pid', 'sub');
        $this->ajaxReturn($menuTree);
    }

    public function getAdsListJson()
    {
        $ads = D("Ads")->getAdsList();
        $this->ajaxReturn($ads);
    }

    public function addFeedbackJson()
    {
        $data = I("post.");
        $data["user_id"] = session("userId");
        D("Feedback")->addFeedback($data);
    }

    public function about()
    {
        $this->display();
    }
}